package com.java202411.contoller;

import com.auth0.jwt.JWT;

import com.java202411.contoller.authorization.AuthorizationOfficer;
import com.java202411.contoller.authorization.RequireAuthorization;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/hello")
    @RequireAuthorization
    public String hello() {
        String accessToken = AuthorizationOfficer.getAccessToken();

        String email = JWT.decode(accessToken).getClaim("email").asString();
        return "Hello, " + email + "!";
    }
}
